package com.mj.app.health;

import android.content.Context;
import android.util.Log;
import android.view.WindowManager;

import com.mj.app.common_util.BaseApplication;
import com.mj.app.health.bean.UserBean;

/**
 * ========================================
 * *
 * title: MyApplication
 * description:
 * *
 * Created by David Hogan on 2018/3/2.
 * ========================================
 */

public class MyApplication  extends BaseApplication {

    private static int screenWidth, screenHeight; // 屏幕宽 高 像素单位
    private static UserBean user;

    public static UserBean getUser() {
        return user;
    }

    public static void setUser(UserBean user) {
        MyApplication.user = user;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        // 继承于BaseApplication的 create 用于初始化各类主工程事件
        initScreen();
    }

    private void initScreen() {
        WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
        screenWidth = wm.getDefaultDisplay().getWidth();
        Log.i("screen-width",screenWidth+"");
        setScreenWidth(screenWidth);
        screenHeight = wm.getDefaultDisplay().getHeight();
        Log.i("screen-height",screenHeight+"");
        setScreenHeight(screenHeight);
    }

    public static int getScreenWidth() {
        return screenWidth;
    }

    public static void setScreenWidth(int screenWidth) {
        MyApplication.screenWidth = screenWidth;
    }

    public static int getScreenHeight() {
        return screenHeight;
    }

    public static void setScreenHeight(int screenHeight) {
        MyApplication.screenHeight = screenHeight;
    }
}
